package com.ruoyi.restaurant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.restaurant.domain.TestChild;
import com.ruoyi.restaurant.service.ITestChildService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测试子1Controller
 * 
 * @author ruoyi
 * @date 2022-04-18
 */
@RestController
@RequestMapping("/testchild/show")
public class TestChildController extends BaseController
{
    @Autowired
    private ITestChildService testChildService;

    /**
     * 查询测试子1列表
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestChild testChild)
    {
        startPage();
        List<TestChild> list = testChildService.selectTestChildList(testChild);
        return getDataTable(list);
    }

    /**
     * 导出测试子1列表
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:export')")
    @Log(title = "测试子1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestChild testChild)
    {
        List<TestChild> list = testChildService.selectTestChildList(testChild);
        ExcelUtil<TestChild> util = new ExcelUtil<TestChild>(TestChild.class);
        util.exportExcel(response, list, "测试子1数据");
    }

    /**
     * 获取测试子1详细信息
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:query')")
    @GetMapping(value = "/{secondId}")
    public AjaxResult getInfo(@PathVariable("secondId") Integer secondId)
    {
        return AjaxResult.success(testChildService.selectTestChildBySecondId(secondId));
    }

    /**
     * 新增测试子1
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:add')")
    @Log(title = "测试子1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestChild testChild)
    {
        return toAjax(testChildService.insertTestChild(testChild));
    }

    /**
     * 修改测试子1
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:edit')")
    @Log(title = "测试子1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestChild testChild)
    {
        return toAjax(testChildService.updateTestChild(testChild));
    }

    /**
     * 删除测试子1
     */
    @PreAuthorize("@ss.hasPermi('testchild:show:remove')")
    @Log(title = "测试子1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{secondIds}")
    public AjaxResult remove(@PathVariable Integer[] secondIds)
    {
        return toAjax(testChildService.deleteTestChildBySecondIds(secondIds));
    }
}
